<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<?php
include("../models/entities/class.AccountEntity.php");
@session_start();
if (isset($_SESSION["Username"])) {
    require_once("../models/webconfig.php");
    require_once("../models/class.connection.php");
    require_once("../models/repositories/class.AccountRepository.php");
    include("../models/repositories/class.GroupAuthorityRepository.php");
    if (isset($_SESSION['Account'])) {
        $groupAuthorityRepository = new GroupAuthorityRepository();
        $account = $_SESSION['Account'];
        if (!$groupAuthorityRepository->CheckExistGroupAuthority($account->GroupID_i, 1))
            header("location:NoAccess.php");
    }
    else {
        header("location:NoAccess.php");
    }
?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Account Manager</title>
            <link href="../content/Layout.css" rel="stylesheet" type="text/css" media="screen"/>
            <script type="text/javascript" src="../scripts/jquery-1.4.2.min.js"></script>
            <script type="text/javascript" src="../scripts/adminaccount.js"></script>
            <script type="text/javascript">
                $(document).ready(function(){

                    DeleteAccount();

                });
            </script>
        </head>

        <body>
            <div id="format">
                <div id="wrapper">
                    <!--Ph?n main menu-->

                <?php
                require_once("../includes/backend_mainnav.php");
                $accres = new AccountRepository();
                $acclist = $accres->GetAllAccount();
                if ($acclist) {
                ?>
                    <div id="addacc">
                        <a href="../views/InsertAccount.php">Thêm Tài Khoản</a></div><br/>
                    <center>
                        <div class="ContentInsert"></div>
                        <div class="clear"></div>
                        <h2>Danh sách tài khoản</h2>
                        <div class="clear"></div>
                        <div class="data" id="AccountContent">
                            <div class="loading"></div>
                            <table class="accman" border="1px">
                                <thead>
                                <td>Tên tài khoản</td>
                                <td>Địa chỉ Email</td>
                                <td>YahooID</td>
                                <td>Nhóm</td>
                                <td>Hỗ trợ</td>
                                <td> </td>
                                <td> </td>
                                </thead>
                            <?php
                            for ($i = 0; $i < count($acclist); $i++) {
                            ?>

                                <tr>
                                    <td><?php echo $acclist[$i]->Username_s; ?></td>
                                    <td><?php echo $acclist[$i]->Email_s; ?></td>
                                    <td><?php echo $acclist[$i]->YahooID_s; ?></td>
                                    <td><?php
                                if ($accres->GetGroupByID($acclist[$i]->GroupID_i)) {
                                    echo $accres->GetGroupByID($acclist[$i]->GroupID_i);
                                } ?></td>

                                <td><?php
                                    if (ord($acclist[$i]->HoTro_b) == 1) {
                                        echo "Có";
                                    }
//                                    <input type="checkbox" name ="hotro" checked readonly="true">
                                    else {
                                        echo "Không";
//                                <input type="checkbox" name ="hotro" readonly="true">
                                    }
                            ?>
                                </td>
                                <td><a href="#" class="deleteAcc" onclick="return false;" code="<?php echo $acclist[$i]->Username_s; ?>"><img src="../content/images/icon-delete-16.gif"/></a></td>
                                <td><a href="../views/UpdateAccount.php?acc=<?php echo $acclist[$i]->Username_s; ?>"><img src="../content/images/icon-edit-16.png"/></a></td>
                            </tr>

                            <?php
                                }
                            ?>
                            </table>
                        </div>
                    </center>
                <?php
                            }
                            require_once("../includes/backend_footer.php");
                ?>
                        </div>
                    </div>
                </body>
            </html>
<?php
                        } else {
                            header("location:../views/Admin_login.php?logout=TRUE");
                        }
?>
